import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:series_play/comm/base/base_state.dart';
import 'package:series_play/comm/ext/context_ext.dart';
import 'package:series_play/pages/account/controller/quick_login_controller.dart';
import 'package:series_play/widget/app_button.dart';
import 'package:series_play/widget/app_color.dart';
import 'package:series_play/widget/app_input.dart';
import 'package:series_play/widget/app_text.dart';

import 'account_register_page.dart';

class AccountLoginPage extends StatefulWidget {
  const AccountLoginPage({super.key});

  @override
  State<AccountLoginPage> createState() => _AccountLoginPageState();
}

class _AccountLoginPageState
    extends BaseControllerState<AccountLoginPage, QuickLoginController> {
  @override
  Widget buildPage(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(32).w,
      alignment: Alignment.center,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          buildTitle(Icons.email, context.tr.email),
          12.verticalSpace,
          AppInput(
            hint: context.tr.pleaseInputEmail,
            keyboardType: TextInputType.emailAddress,
          ),
          20.verticalSpace,
          buildTitle(Icons.lock_outline, context.tr.password),
          12.verticalSpace,
          AppInput(
            hint: context.tr.pleaseInputPassword,
            obscureText: true,
            keyboardType: TextInputType.visiblePassword,
          ),
          34.verticalSpace,
          AppButton(context.tr.login, isGradient: false, onTap: () {}),
          12.verticalSpace,
          Row(
            children: [
              const Spacer(),
              GestureDetector(
                onTap: () {
                  Get.to(() => AccountRegisterPage());
                },
                child: Text(
                  context.tr.accountRegister,
                  style: TextStyle(
                    color: AppColor.white_60,
                    fontSize: 14.sp,
                    decoration: TextDecoration.underline,
                    decorationColor: AppColor.white_60,
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }

  Widget buildTitle(IconData icon, String title) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 3).w,
      child: Row(
        children: [
          Icon(icon, size: 12.w, color: AppColor.white_40),
          7.horizontalSpace,
          AppText.secondary(title, color: AppColor.white_40),
        ],
      ),
    );
  }

  @override
  QuickLoginController createController() {
    return Get.find();
  }

  @override
  bool isFindGetController() {
    return true;
  }
}
